//
//  XMSharePlainView.m
//  XiaoMiao
//
//  Created by 23 on 2017/11/9.
//  Copyright © 2017年 smallyou. All rights reserved.
//

#import "XMSharePlainView.h"
#import "XMSharePlainButton.h"

@interface XMSharePlainView ()

@property (weak, nonatomic) IBOutlet XMSharePlainButton *wechatFriendsButton;

@property (weak, nonatomic) IBOutlet XMSharePlainButton *qqButton;

@property (weak, nonatomic) IBOutlet XMSharePlainButton *weiboButton;

@property (weak, nonatomic) IBOutlet XMSharePlainButton *wechatButton;


@end

@implementation XMSharePlainView


+ (instancetype)sharePlainView
{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] firstObject];
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    self.wechatFriendsButton.tag = XMShareTypeWechatFriends;
    self.qqButton.tag = XMShareTypeQQ;
    self.weiboButton.tag = XMShareTypeWeibo;
    self.wechatButton.tag = XMShareTypeWechat;
    
    [self.wechatFriendsButton addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapShare:)]];
    [self.qqButton addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapShare:)]];
    [self.weiboButton addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapShare:)]];
    [self.wechatButton addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapShare:)]];
    
}


- (IBAction)cancelButtonClicked:(id)sender {
    if ([self.delegate respondsToSelector:@selector(sharePlainDidCancel:)]) {
        [self.delegate sharePlainDidCancel:self];
    }
    
}

- (void)tapShare:(UITapGestureRecognizer *)tap
{
    XMShareType type = (XMShareType)tap.view.tag;
    
    if ([self.delegate respondsToSelector:@selector(sharePlain:didSelectedShareType:)]) {
        [self.delegate sharePlain:self didSelectedShareType:type];
    }
}


@end
